package com.rgs.se.algorithm.recursive;


/**
 * @author Ren Gaoshuai
 * @ClassName Factorial
 * @Description 递归，n的阶乘
 * @date 2021-10-22 17:34
 **/
public class Factorial {

   int fac(int n){
       if (n < 0){
           System.out.println("参数不合法！");
       }
       if(n == 1){
           return 1;
       }
       return fac(n-1)*n;
   }


    public static void main(String[] args) {
        int fac = new Factorial().fac(3);
        System.out.println(fac);
    }

}
